package com.qth.valet.controller;

import com.qth.valet.common.annotation.Release;
import com.qth.valet.common.utils.ResponseResult;
import com.qth.valet.entity.vo.InsuranceSucVo;
import com.qth.valet.entity.vo.InsuranceVo;
import com.qth.valet.service.InsuranceService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@RequestMapping("/qth/insurance")
public class InsuranceController {

    private final InsuranceService insuranceService;

    //@Logs(operation = "微信获取用户openid")
    @GetMapping("/getbalance")
    @Release
    public ResponseResult getbalance() {
        Double balance = insuranceService.getBalance();
        if (balance == null) {
            return ResponseResult.fail("查不到余额");
        }
        return ResponseResult.success("查询成功。", balance);
    }

    @PostMapping("/orderUpOne")
    @Release
    public ResponseResult orderUpOne(@RequestBody InsuranceVo insuranceVo) {
        return insuranceService.orderUpOne(insuranceVo);
    }

    @PostMapping("/orderSuc")
    @Release
    public ResponseResult orderSuc(@RequestBody InsuranceSucVo insuranceSucVo) {
        return insuranceService.orderSuc(insuranceSucVo);
    }

    @GetMapping("/search")
    @Release
    public ResponseResult search(String orderId) {
        return insuranceService.search(orderId);
    }

}
